package afk.lib;

import java.text.*;
import java.util.*;
import java.util.logging.*;
import java.util.logging.Formatter;

public class AfkFormatter extends Formatter
{

	private static final SimpleDateFormat SIMPLE_DATE_FORMAT = new SimpleDateFormat("yyyy:MM:dd-HH:mm:SS.sss");

	@Override
	public String format(final LogRecord record)
	{
		final String level = getLevel(record);
		return new StringBuffer(level).append(": ").append(record.getMessage()).append(" (").append(record.getSourceClassName()).append("->").append(record.getSourceMethodName()).append("(").append(record.getThreadID()).append(")) ::" + SIMPLE_DATE_FORMAT.format(new Date(record.getMillis()))).append("\r\n").toString();
	}

	private String getLevel(final LogRecord record)
	{
		if (record.getLevel() == Level.INFO)
			return "INFO ";
		if (record.getLevel() == Level.WARNING)
			return "WARNG";
		if (record.getLevel() == Level.SEVERE)
			return "ERROR";
		return "DEBUG";
	}

}
